using System;
using TagTool.Core;

namespace TagTool.Nodes.Math
{
    class Equality : BaseNode
    {
		private InputSlot slotA;
		private InputSlot slotB;
		private OutputSlot slotC;

        private bool oldValue = true;

        public Equality() : base()
		{
			Name = "Equality";
			slotA = new InputSlot(this, "A", new Object());
            slotB = new InputSlot(this, "B", new Object());
			slotC = new OutputSlot(this, "C", typeof(bool));
			slotC.Value = true;
		}

		[NodeAttribute(SlotType.Input, Show = true)]
		public InputSlot SlotA
		{
			get { return slotA; }
		}

		[NodeAttribute(SlotType.Input, Show = true)]
		public InputSlot SlotB
		{
			get { return slotB; }
		}

		[NodeAttribute(SlotType.Output, Show = true)]
		public OutputSlot SlotC
		{
			get { return slotC; }
		}

		public override void Update(Object sender)
		{
            bool c = slotA.Value.Equals(slotB.Value);
            if (c != oldValue)
            {
            	oldValue = c;
                slotC.Value = c;
                CastTrigger();
            }
		}
	}

}
